package com.cheyun.netsalev3.repository

import com.cheyun.netsalev3.bean.dm.DmKefu
import com.cheyun.netsalev3.utils.api.*
import com.cheyun.netsalev3.utils.api.dm.DmApiCallback
import com.cheyun.netsalev3.utils.api.dm.DmApiException
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import kotlin.reflect.KFunction1

class DmChatRepository: BaseRepository() {
    //获取通道列表
    fun getData(kefuPhone:String,channelId:Int, kFunction1: KFunction1<List<DmKefu>, Unit>) {
        DmApiClient.getInstance().getKefuList(kefuPhone,channelId)
                .subscribeOn(Schedulers.io())
                .subscribeOn(AndroidSchedulers.mainThread())
                .subscribe(object : DmApiCallback<DmBaseResp<List<DmKefu>, Any>>() {
                    override fun onSuccess(t: DmBaseResp<List<DmKefu>, Any>) {
                        var list = t.list!!
                        kFunction1(list)
                    }

                    override fun onError(ex: DmApiException) {

                    }
                })
    }



}